﻿using Google.Protobuf;
using Server.Framework.Message;
using Server.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Server.Message.Response
{
    /// <summary>
    /// Author: Leil
    /// Description: 角色列表回复消息
    /// CreateTime: 2020/5/13 12:31:32
    /// </summary>
    class RoleListResp : ResponseBaseMessage
    {
        public List<RoleDao> Roles { get; } = new List<RoleDao>();

        public int Count { get; set; }

        public RoleListResp(int msgId):base(msgId)
        {

        }

        public override byte[] Serialize()
        {
            RoleList msg = new RoleList();
            Roles.ForEach(role =>
            {
                Role r = new Role
                {
                    Id = role.ID,
                    RoleName = role.RoleName ?? "",
                    Status = role.Status,
                    Creator = role.Creator ?? "",
                    CreateTime = role.CreateTime ?? "",
                    Updator = role.Updator ?? "",
                    UpdateTime = role.UpdateTime ?? "",
                };
                msg.Roles.Add(r);
            });
            msg.Count = Count;
            return msg.ToByteArray();
        }
    }
}
